package net.xdclass.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;

import static net.xdclass.enums.ProductOrderStateEnum.PAY;

public class AliPayConfig {

    /**
     * 应用私钥
     */
    public static final String APP_PRI_KEY = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzWtOjMVovnJN66P0mPO96icH7icT5/RKjZ05mEy2lUXmhCReKN7rN4xFrDC/NSlbObf0UADIRfoJOpwAUH/bPCIiusWwAomy4+P2/4RBlr0Pu11o1MPD3SENfQGfuhVmzvImfioDda1VnJoabYhG27dDrZFeF4nCyQZxKUJIMAAf+BQBsZ9FbzAZH7H6D8Uw2bMZ/yAAsWJsTJgq3TcDJgnJXz4GJDjXZU97kr8ZV/vaKzcZzsmX9bMpc75LmB2cxSKeWUfD2oy/csxHpNYnyplfJqu/k1LkdcGaZw4u5NURWdK6n0TVMj9DHMp6x/mdC9ojD+aDIe8aH5KI+5m/DAgMBAAECggEAXUvy6WIjwr6VLQuDm994x2pfgORSlaPijSOQ8aIqTWPLfExJdXm176GdjuzA9O4lp64pRr0vTlBbomRWsyFJdrq+tvjN8KqNGc9T1/tQV0TLdrOJVkAGKOvrN+I97iJp3ghGIrqefA94VncA8FUcV+bvlXMV4CxBaUid7z5oKlr8Ds0iRI5lAgyZy+Wq2gPEryH9bEpa9nORoMIcCdFHwod+8PBywqZuFjrEuK43UFw/wmwb4kUYqdBwpwGqHao2HK3V3mtOE25/mRfoZ0XU/ZFUVql47UVcgZ/04EUgFFWdiVVBOZQuRtFpQcI9yxTmYiK1xU9295Sm+5J4aiI/WQKBgQD7JU32M8xfrw6V1cEfHzaSRD8b3r7FYSq6o4linXsNm6RIKX27kQSb8fjrFRt1CWWxXm11+3w6SeFSHFHSNbFCum32PgCCDyWowZBjZnVGmejy/zhFl09BBnNKpNDDkTzhMk2Koj4C8IwMXG5h8Ncl2dDsfbV0ss6RjtohS0esfQKBgQC20ksIb6zvvsuaW/X9papQMW6JCawoRvODg2akyET+reJ6pcCLosSQAk6q4nF3hlk+sf2MrxUR9cifQJ8Q3uv8Jci73wLnlLX7iJCdQq/zbAlOWmFd64XNGlOuKVVU2syhqBnBQrKf0LBza5qWJoQv8ZzrS3narQWrf4WciziBPwKBgQC2elp1IxnCBC3yzIcvl7xM9m1sUKIIRBuJ1L1D++ym7ImnLQ6ANFRHAr+7/3Adz6AmCdg6u2l96KRgxtbkh8KuG0s+ebpgxaS1Qz8oGg/oJnhN5wb5+YDKXGd0uuA82NCFR8lzi4LHHASGDrrdSuLoS6Uzz/sCOdFBjawMOOhw+QKBgQCsErq0sgffj4ErRCsAFhF7cUtMiGIVdtJ0khTmO+lUnG1yatgTlZvUv5czl/acPUN6kyTGaXQ3d1LhMX2F74vFw/pvebPOLFYs7ZjPq5jYUHNh4AeM0sUZCxJ/9j9uopHABexXzmM5sL6jpD/X22DHj23WuS9z9y5DAL/NW+xPGQKBgCkdMh+P/9i5Kb8w//NMsjhAnvangjcPZAdzxGo17vW+sFtlndZzs/0sBZINzmyR/w0w4QuRfFDo2SmDiFIDhYRbfK9j21wezazVSef/J514hHC7D5IQiBIPe9zyOSxBmkPnTiB/zf+dySiL/GnztpV664fQUq1JVm6hUAfGRMz9";

    /**
     * 支付宝公钥
     */
    public static final String ALIPAY_PUB_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmRUZtRPOYio+CuvXctu4qDzVgcXn9ihhnM+XZaoKsegh/uBCs4tW/+gGw365q3mvsSo4fCROTE+Y1jTwcZwR4fUflJ+h3lCgguFCo7Jld09VA+Px61zDlgfypIgXjik7h8dMzxXK7i4nWrPPRpevu/eUoAesja+uw8dlCTGyZXh9I2mKEtH51iiVAiBZip+N3DqzOISfx2d6siG1yAdpFFgEuNhArKDrOpYSYEmGfFYj022H7b2QkIjMQN1QsXYnuNUhaiyWZkrwxH/L1OqeW4FUxks4EdM9Cr9TDHwaZKfkpTRlJ5sqwPwojq15hUlApu8HYNwEanE30g76WHcSpQIDAQAB";

    /**
     * 支付宝APPID
     */
    public static final String APPID = "9021000140671882";

    /**
     * 签名类型
     */
    public static final String SIGN_TYPE = "RSA2";

    /**
     * 字符编码
     */
    public static final String CHARSET = "UTF-8";

    /**
     * 返回参数的格式
     */
    public static final String FORMAT = "json";

    /**
     * 支付宝网关地址 TODO
     */
    public static final String PAY_GATEWAY = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    private AliPayConfig(){}

    private volatile static AlipayClient instance = null;

    /**
     * 获取单列模式, 双重锁
     * @return
     */
    public static AlipayClient getInstance(){

        if (instance == null){
            synchronized (AliPayConfig.class){
                if (instance == null){
                    instance = new DefaultAlipayClient(PAY_GATEWAY, APPID, APP_PRI_KEY, FORMAT, CHARSET, ALIPAY_PUB_KEY, SIGN_TYPE);
                }
            }
        }
        return instance;
    }
}
